﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IRC4N00bz;
using IRC4N00bz.ArgTypes;
using System.IO;

namespace RawLogger {
    public class RawLogger : Plugin {
        Bot bot;
        public RawLogger(Bot bot)
            : base(bot) {
            this.bot = bot;
            bot.OnRawMessage += new EventHandlers.RawMsgHandler(bot_OnRawMessage);
        }

        void bot_OnRawMessage(RawMsgArgs e) {
            string todaysLog = string.Format(@"{0}\{1}-{2}-{3}_RawLog.txt",
                Bot.LOGDIR, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Year);
            string[] parts = e.RawMessage.Split(' ');
            if (parts[1] != "PONG") {
                using (StreamWriter sw = new StreamWriter(todaysLog, true)) {
                    sw.WriteLine("{0} {1}", DateTime.Now, e.RawMessage);
                }
            }
        }

    }
}
